Last compiled on : 07 February, 2022
---
title: "Kerala weather warning dashboard"
output:
flexdashboard::flex_dashboard:
theme:
bg: "#101010"
fg: "#FDF7F7"
primary: "#fa8072"
base_font:
google: Prompt
code_font:
google: JetBrains Mono
orientation: columns
vertical_layout: scroll
social: menu
source_code: embed
---
Last compiled on : `r format(Sys.time(), '%d %B, %Y')`
```{r setup, include=FALSE}
if (!require("pacman")) install.packages("pacman")
pacman::p_load(tidyverse,sf,glue,lubridate, flexdashboard, ggiraph)
# load data
map_in <- st_read("./data/kerala/kerala_lak.shp")
weather_a <- read_csv("./data/weather_warn.csv")
# re-code
weather_a[weather_a == "No rain"] <- "0"
weather_a[weather_a == "L." ] <- "1"
weather_a[weather_a == "VL" ] <- "0"
weather_a[weather_a == "VL." ] <- "0"
weather_a[weather_a == "M" ] <- "2"
weather_a[weather_a == "M." ] <- "2"
weather_a[weather_a == "H" ] <- "3"
weather_a[weather_a == "H." ] <- "3"
weather_a[weather_a == "VH" ] <- "4"
weather_a[weather_a == "VH." ] <- "4"
weather_a[weather_a == "XH" ] <- "5"
weather_a[weather_a == "XH." ] <- "5"
# col
colnames(weather_a)[1] <- "Name_1"
# shp + csv
map_latest <- merge(map_in,weather_a, by ="Name_1") %>%
filter(!grepl('Lakshadweep', Name_1))
# Col names
col2 <- sym(names(map_latest)[2])
col3 <- sym(names(map_latest)[3])
col4 <- sym(names(map_latest)[4])
col5 <- sym(names(map_latest)[5])
col6 <- sym(names(map_latest)[6])
```
Column {.tabset}
-----------------------------------------------------------------------
### Day 1
```{r fig.width=8, fig.height=12, fig.fullwidth=TRUE }
# Plot Day 1
g1 <- ggplot(map_latest) +
geom_sf(aes(fill = !!col2)) +
geom_sf_interactive(aes(fill = !!col2,tooltip = Name_1))+
scale_fill_manual(
labels = c(
"No alert",
"Green alert",
"Yello alert",
"Orange alert",
"Red alert",
"Extreme heavy rainfall"
),
values = c('White', 'Green', 'Yellow', 'Orange', 'Red', '#8B0000')
) +
labs(title = "Kerala weather warning",
subtitle = glue("Date: {col2} {year(now())}"),
caption = "Source: IMD, Created by: Open-oven") +
theme_void()
girafe( ggobj = g1)
```
### Day 2
```{r fig.width=8, fig.height=12, fig.fullwidth=TRUE}
# Plot Day 2
g2 <- ggplot(map_latest) +
geom_sf(aes(fill = !!col3)) +
geom_sf_interactive(aes(fill = !!col3,tooltip = Name_1))+
scale_fill_manual(
labels = c(
"No alert",
"Green alert",
"Yello alert",
"Orange alert",
"Red alert",
"Extreme heavy rainfall"
),
values = c('White', 'Green', 'Yellow', 'Orange', 'Red', '#8B0000')
) +
labs(title = "Kerala weather warning",
subtitle = glue("Date: {col3} {year(now())}"),
caption = "Source: IMD, Created by: Open-oven") +
theme_void()
girafe( ggobj = g2)
```
### Day 3
```{r fig.width=8, fig.height=12, fig.fullwidth=TRUE}
# Plot Day 3
g3 <- ggplot(map_latest) +
geom_sf(aes(fill = !!col4)) +
geom_sf_interactive(aes(fill = !!col4,tooltip = Name_1))+
scale_fill_manual(
labels = c(
"No alert",
"Green alert",
"Yello alert",
"Orange alert",
"Red alert",
"Extreme heavy rainfall"
),
values = c('White', 'Green', 'Yellow', 'Orange', 'Red', '#8B0000')
) +
labs(title = "Kerala weather warning",
subtitle = glue("Date: {col4} {year(now())}"),
caption = "Source: IMD, Created by: Open-oven") +
theme_void()
girafe( ggobj = g3)
```
### Day 4
```{r fig.width=8, fig.height=12, fig.fullwidth=TRUE}
# Plot Day 4
g4 <- ggplot(map_latest) +
geom_sf(aes(fill = !!col5)) +
geom_sf_interactive(aes(fill = !!col5,tooltip = Name_1))+
scale_fill_manual(
labels = c(
"No alert",
"Green alert",
"Yello alert",
"Orange alert",
"Red alert",
"Extreme heavy rainfall"
),
values = c('White', 'Green', 'Yellow', 'Orange', 'Red', '#8B0000')
) +
labs(title = "Kerala weather warning",
subtitle = glue("Date: {col5} {year(now())}"),
caption = "Source: IMD, Created by: Open-oven") +
theme_void()
girafe( ggobj = g4)
```
### Day 5
```{r fig.width=8, fig.height=12, fig.fullwidth=TRUE}
# Plot Day 5
g5 <- ggplot(map_latest) +
geom_sf(aes(fill = !!col6)) +
geom_sf_interactive(aes(fill = !!col6,tooltip = Name_1))+
scale_fill_manual(
labels = c(
"No alert",
"Green alert",
"Yello alert",
"Orange alert",
"Red alert",
"Extreme heavy rainfall"
),
values = c('White', 'Green', 'Yellow', 'Orange', 'Red', '#8B0000')
) +
labs(title = "Kerala weather warning",
subtitle = glue("Date: {col6} {year(now())}"),
caption = "Source: IMD, Created by: Open-oven") +
theme_void()
girafe( ggobj = g5)
#ggiraph(code = {print(g5)}, zoom_max = 1, width = 10)
```